package com.lams.service.system.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lams.jdbc.IBaseDAO;
import com.lams.jdbc.QueryUtils;
import com.lams.service.BaseFacade;
import com.lams.service.system.IButtonFacade;

public class ButtonFacade extends BaseFacade implements IButtonFacade {
	public String queryBtnByRole;
//	private IBaseDAO dao;
//	
//	public IBaseDAO getDao() {
//		return dao;
//	}
//	public void setDao(IBaseDAO dao) {
//		this.dao = dao;
//	}
	
	public String getQueryBtnByRole() {
		return queryBtnByRole;
	}
	public void setQueryBtnByRole(String queryBtnByRole) {
		this.queryBtnByRole = queryBtnByRole;
	}
	@SuppressWarnings("rawtypes")
	@Override
	public List<Map> getButtonByRole(int roleId) {
		Map params = new HashMap();
		params.put("ROLE_ID", roleId);
		String sql = QueryUtils.getSqlBySqlCode(queryBtnByRole, params);
		List<Map> list = QueryUtils.executeQuery(sql);;
		List<Map> flist = new ArrayList<Map>();
		Map<String,List<Map>> result = new HashMap<String, List<Map>>();
		List<Map> btns = null;
		for(Map item:list){
			btns = result.get(String.valueOf(item.get("FUN_ID")));
			if(btns==null){
				btns = new ArrayList<Map>();
				result.put(String.valueOf(item.get("FUN_ID")), btns);
			}
			btns.add(item);
		}
		flist.add(result);
		return flist;
	}
}
